export function isDisabled(dataNode, skipType) {
  if (!dataNode) {
    return true;
  }

  var _dataNode$data$node = dataNode.data.node,
      disabled = _dataNode$data$node.disabled,
      disableCheckbox = _dataNode$data$node.disableCheckbox;

  switch (skipType) {
    case 'checkbox':
      return disabled || disableCheckbox;

    default:
      return disabled;
  }
}
export default function useKeyValueMapping(cacheKeyMap, cacheValueMap) {
  var getEntityByKey = function getEntityByKey(key) {
    var skipType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'select';
    var ignoreDisabledCheck = arguments.length > 2 ? arguments[2] : undefined;
    var dataNode = cacheKeyMap.value.get(key);

    if (!ignoreDisabledCheck && isDisabled(dataNode, skipType)) {
      return null;
    }

    return dataNode;
  };

  var getEntityByValue = function getEntityByValue(value) {
    var skipType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'select';
    var ignoreDisabledCheck = arguments.length > 2 ? arguments[2] : undefined;
    var dataNode = cacheValueMap.value.get(value);

    if (!ignoreDisabledCheck && isDisabled(dataNode, skipType)) {
      return null;
    }

    return dataNode;
  };

  return [getEntityByKey, getEntityByValue];
}